package com.winit.openapi.ups.controller;


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import com.winit.openapi.constants.ErrorCode;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.exception.ApiException;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ups.spi.deliveryWay.DeliveryWayService;
import com.winit.ups.spi.deliveryWay.command.DeliveryWayVo;
import com.winit.ups.spi.deliveryWay.command.QueryAllDeliverWayCommand;

@Controller
@RequestMapping(value = "/ups/deliveryWay")
public class UpsDeliveryWayController extends BaseController {

	@Resource
	private DeliveryWayService deliveryWayService;

	/**
	 * 获取所有发货方式
	 * 
	 * @param requestMsg
	 * @param responseMsg
	 * @return
	 */
	@RequestMapping(value = "/getAlldeliveryWay")
	public String getAllDeliveryWay(@ModelAttribute RequestMsg requestMsg,@ModelAttribute ResponseMsg responseMsg) {
		QueryAllDeliverWayCommand command = new QueryAllDeliverWayCommand();
		List<DeliveryWayVo> voList = deliveryWayService.queryAllDeliverWay(command);
		if (voList != null && voList.size() > 0) {
			Map<String, Object> dataMap = new HashMap<String, Object>();
			dataMap.put("deliveryWays", voList);
			responseMsg.setData(dataMap);
			return SUCCESS;
		} else {
			throw new ApiException(ErrorCode.FIELD_TYPE_ERROR, "data");
		}

	}

}
